package com.shushan.pages.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.base.Constants;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;


/**
 * @ClassName: ExerciseRecordBean
 * @Desciption: //错题,收藏记录列表bean
 * @author: zhangshihao
 * @date: 2018-04-21
 */
public class ExerciseRecordBean extends NetBaseBean {

    public TypesExerciseRecordBean syncExerciseBean;
    public TypesExerciseRecordBean smartExerciseBean;
    public TypesExerciseRecordBean learnByDoExerciseBean;
    public TypesExerciseRecordBean keyPointExerciseBean;
    public TypesExerciseRecordBean difficultPointExerciseBean;
    public TypesExerciseRecordBean easyWrongExerciseBean;
    public TypesExerciseRecordBean specialTopicExerciseBean;
    public TypesExerciseRecordBean strangeWordsExerciseBean;
    public TypesExerciseRecordBean speakingExerciseBean;
    public TypesExerciseRecordBean englishWordsExerciseBean;
    public TypesExerciseRecordBean hearingExerciseBean;
    public TypesExerciseRecordBean readReciteExerciseBean;
    public TypesExerciseRecordBean oralCalculateExerciseBean;
    public TypesExerciseRecordBean chineseBranchExerciseBean;
    public TypesExerciseRecordBean machBranchExerciseBean;
    public TypesExerciseRecordBean englishBranchExerciseBean;

    public List<HashMap<Integer,Integer>> nums;
    public List<TypesExerciseRecordBean> typesExerciseRecordBeans;

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject != null){
            typesExerciseRecordBeans = new ArrayList<>();
            nums = new ArrayList<>();

            JSONObject syncJobj = jsonObject.optJSONObject(Constants.SYNC_EXERCISE);
            syncExerciseBean = new TypesExerciseRecordBean();
            syncExerciseBean.type = Constants.TYPE_SYNC_EXERCISE;
            syncExerciseBean.initByJson(syncJobj);
            typesExerciseRecordBeans.add(syncExerciseBean);
            int syncNum = syncJobj.optInt("all");
            HashMap<Integer,Integer> syncMap = new HashMap();
            syncMap.put(Constants.TYPE_SYNC_EXERCISE,syncNum);
            nums.add(syncMap);

            JSONObject smartJobj = jsonObject.optJSONObject(Constants.SMART_EXERCISE);
            smartExerciseBean = new TypesExerciseRecordBean();
            smartExerciseBean.type = Constants.TYPE_SMART_EXERCISE;
            smartExerciseBean.initByJson(smartJobj);
            typesExerciseRecordBeans.add(smartExerciseBean);
            int smartNum = smartJobj.optInt("all");
            HashMap<Integer,Integer> smartMap = new HashMap();
            smartMap.put(Constants.TYPE_SMART_EXERCISE,smartNum);
            nums.add(smartMap);

            JSONObject learnByDoJobj = jsonObject.optJSONObject(Constants.LEARN_BY_DO);
            learnByDoExerciseBean = new TypesExerciseRecordBean();
            learnByDoExerciseBean.type = Constants.TYPE_LEARN_BY_DO;
            learnByDoExerciseBean.initByJson(learnByDoJobj);
            typesExerciseRecordBeans.add(learnByDoExerciseBean);
            int learnByDoNum = learnByDoJobj.optInt("all");
            HashMap<Integer,Integer> learnByDoMap = new HashMap();
            learnByDoMap.put(Constants.TYPE_LEARN_BY_DO,learnByDoNum);
            nums.add(learnByDoMap);

            JSONObject keyPointJobj = jsonObject.optJSONObject(Constants.KEY_POINT_EXERCISE);
            keyPointExerciseBean = new TypesExerciseRecordBean();
            keyPointExerciseBean.type = Constants.TYPE_KEY_POINT_EXERCISE;
            keyPointExerciseBean.initByJson(keyPointJobj);
            typesExerciseRecordBeans.add(keyPointExerciseBean);
            int keyPointNum = keyPointJobj.optInt("all");
            HashMap<Integer,Integer> keyPointMap = new HashMap();
            keyPointMap.put(Constants.TYPE_KEY_POINT_EXERCISE,keyPointNum);
            nums.add(keyPointMap);

            JSONObject difficultJobj = jsonObject.optJSONObject(Constants.DIFFICULT_POINT_EXERCISE);
            difficultPointExerciseBean = new TypesExerciseRecordBean();
            difficultPointExerciseBean.type = Constants.TYPE_DIFFICULT_POINT_EXERCISE;
            difficultPointExerciseBean.initByJson(difficultJobj);
            typesExerciseRecordBeans.add(difficultPointExerciseBean);
            int difficultPointNum = difficultJobj.optInt("all");
            HashMap<Integer,Integer> difficultPointMap = new HashMap();
            difficultPointMap.put(Constants.TYPE_DIFFICULT_POINT_EXERCISE,difficultPointNum);
            nums.add(difficultPointMap);

            JSONObject easyWrongJobj = jsonObject.optJSONObject(Constants.EASY_WRONG_EXERCISE);
            easyWrongExerciseBean = new TypesExerciseRecordBean();
            easyWrongExerciseBean.type = Constants.TYPE_EASY_WRONG_EXERCISE;
            easyWrongExerciseBean.initByJson(easyWrongJobj);
            typesExerciseRecordBeans.add(easyWrongExerciseBean);
            int easyWrongNum = easyWrongJobj.optInt("all");
            HashMap<Integer,Integer> easyWrongMap = new HashMap();
            easyWrongMap.put(Constants.TYPE_EASY_WRONG_EXERCISE,easyWrongNum);
            nums.add(easyWrongMap);

            JSONObject specialJobj = jsonObject.optJSONObject(Constants.SPECIAL_TOPIC_EXERCISE);
            specialTopicExerciseBean = new TypesExerciseRecordBean();
            specialTopicExerciseBean.type = Constants.TYPE_SPECIAL_TOPIC_EXERCISE;
            specialTopicExerciseBean.initByJson(specialJobj);
            typesExerciseRecordBeans.add(specialTopicExerciseBean);
            int specialTopicNum = specialJobj.optInt("all");
            HashMap<Integer,Integer> specialTopicMap = new HashMap();
            specialTopicMap.put(Constants.TYPE_SPECIAL_TOPIC_EXERCISE,specialTopicNum);
            nums.add(specialTopicMap);

            JSONObject strangeWordObj = jsonObject.optJSONObject(Constants.STRANGE_WORDS_EXERCISE);
            strangeWordsExerciseBean = new TypesExerciseRecordBean();
            strangeWordsExerciseBean.type = Constants.TYPE_STRANGE_WORDS_EXERCISE;
            strangeWordsExerciseBean.initByJson(strangeWordObj);
            typesExerciseRecordBeans.add(strangeWordsExerciseBean);
            int strangeWordsNum = strangeWordObj.optInt("all");
            HashMap<Integer,Integer> strangeWordsMap = new HashMap();
            strangeWordsMap.put(Constants.TYPE_STRANGE_WORDS_EXERCISE,strangeWordsNum);
            nums.add(strangeWordsMap);

            JSONObject speakingObj = jsonObject.optJSONObject(Constants.SPEAKING_EXERCISE);
            speakingExerciseBean = new TypesExerciseRecordBean();
            speakingExerciseBean.type = Constants.TYPE_SPEAKING_EXERCISE;
            speakingExerciseBean.initByJson(speakingObj);
            typesExerciseRecordBeans.add(speakingExerciseBean);
            int speakingNum = speakingObj.optInt("all");
            HashMap<Integer,Integer> speakingMap = new HashMap();
            speakingMap.put(Constants.TYPE_SPEAKING_EXERCISE,speakingNum);
            nums.add(speakingMap);

            JSONObject englishWordsObj = jsonObject.optJSONObject(Constants.ENGLISH_WORDS_EXERCISE);
            englishWordsExerciseBean = new TypesExerciseRecordBean();
            englishWordsExerciseBean.type = Constants.TYPE_ENGLISH_WORDS_EXERCISE;
            englishWordsExerciseBean.initByJson(englishWordsObj);
            typesExerciseRecordBeans.add(englishWordsExerciseBean);
            int englishWordsNum = englishWordsObj.optInt("all");
            HashMap<Integer,Integer> englishWordsMap = new HashMap();
            englishWordsMap.put(Constants.TYPE_ENGLISH_WORDS_EXERCISE,englishWordsNum);
            nums.add(englishWordsMap);

            JSONObject hearingObj = jsonObject.optJSONObject(Constants.HEARING_EXERCISE);
            hearingExerciseBean = new TypesExerciseRecordBean();
            hearingExerciseBean.type = Constants.TYPE_HEARING_EXERCISE;
            hearingExerciseBean.initByJson(hearingObj);
            typesExerciseRecordBeans.add(hearingExerciseBean);
            int hearingNum = hearingObj.optInt("all");
            HashMap<Integer,Integer> hearingMap = new HashMap();
            hearingMap.put(Constants.TYPE_HEARING_EXERCISE,hearingNum);
            nums.add(hearingMap);

            JSONObject readReciteObj = jsonObject.optJSONObject(Constants.READ_RECITE_EXERCISE);
            readReciteExerciseBean = new TypesExerciseRecordBean();
            readReciteExerciseBean.type = Constants.TYPE_READ_RECITE_EXERCISE;
            readReciteExerciseBean.initByJson(readReciteObj);
            typesExerciseRecordBeans.add(readReciteExerciseBean);
            int readReciteNum = readReciteObj.optInt("all");
            HashMap<Integer,Integer> readReciteMap = new HashMap();
            readReciteMap.put(Constants.TYPE_READ_RECITE_EXERCISE,readReciteNum);
            nums.add(readReciteMap);

            JSONObject ocObj = jsonObject.optJSONObject(Constants.ORAL_CALCULATE_EXERCISE);
            oralCalculateExerciseBean = new TypesExerciseRecordBean();
            oralCalculateExerciseBean.type = Constants.TYPE_ORAL_CALCULATE_EXERCISE;
            oralCalculateExerciseBean.initByJson(ocObj);
            typesExerciseRecordBeans.add(oralCalculateExerciseBean);
            int ocNum = ocObj.optInt("all");
            HashMap<Integer,Integer> ocMap = new HashMap();
            ocMap.put(Constants.TYPE_ORAL_CALCULATE_EXERCISE,ocNum);
            nums.add(ocMap);

            JSONObject chineseBranchObj = jsonObject.optJSONObject(Constants.CHINESE_BRANCH_EXERCISE);
            chineseBranchExerciseBean = new TypesExerciseRecordBean();
            chineseBranchExerciseBean.type = Constants.TYPE_CHINESE_SECT_EXERCISE;
            chineseBranchExerciseBean.initByJson(chineseBranchObj);
            typesExerciseRecordBeans.add(chineseBranchExerciseBean);
            int chineseBranchNum = chineseBranchObj.optInt("all");
            HashMap<Integer,Integer> chineseBranchMap = new HashMap();
            chineseBranchMap.put(Constants.TYPE_CHINESE_SECT_EXERCISE,chineseBranchNum);
            nums.add(chineseBranchMap);

            JSONObject machBranchObj = jsonObject.optJSONObject(Constants.MATH_BRANCH__EXERCISE);
            machBranchExerciseBean = new TypesExerciseRecordBean();
            machBranchExerciseBean.type = Constants.TYPE_MACH_SECT_EXERCISE;
            machBranchExerciseBean.initByJson(machBranchObj);
            typesExerciseRecordBeans.add(machBranchExerciseBean);
            int machBranchNum = machBranchObj.optInt("all");
            HashMap<Integer,Integer> machBranchMap = new HashMap();
            machBranchMap.put(Constants.TYPE_MACH_SECT_EXERCISE,machBranchNum);
            nums.add(machBranchMap);

            JSONObject englishBranchObj = jsonObject.optJSONObject(Constants.ENGLISH_BRANCH__EXERCISE);
            englishBranchExerciseBean = new TypesExerciseRecordBean();
            englishBranchExerciseBean.type = Constants.TYPE_ENGLISH_SECT_EXERCISE;
            englishBranchExerciseBean.initByJson(englishBranchObj);
            typesExerciseRecordBeans.add(englishBranchExerciseBean);
            int englishBranchNum = ocObj.optInt("all");
            HashMap<Integer,Integer> englishBranchMap = new HashMap();
            englishBranchMap.put(Constants.TYPE_ENGLISH_SECT_EXERCISE,englishBranchNum);
            nums.add(englishBranchMap);
        }
    }

}
